import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
    state: sessionStorage.getItem('state') ? JSON.parse(sessionStorage.getItem('state')) : {
        user: {
            userId: "",
            username: "",
            orderTypeNames: []
        }
    },
    getters: {
        getUser(state){
            return state.user;
        }
    },
    mutations: {
        updateUser(state,user){
            state.user = user;
        }
    },
    actions: {
        asyncUpdateUser(content, user){
            content.commit('updateUser', user);
        }
    }
})
